import { models } from '@/.umi/plugin-model/Provider'
import React,{useEffect,useState} from 'react'
import { useDispatch , useSelector,useHistory,useParams,useLocation} from 'umi'
const LoginPage:React.FC =() => {
  let [user_name,setUserName] = useState('chenmanjie')
  let [user_pwd,setUserpwd] = useState('Chenmanjie123!')

  const dispatch = useDispatch();
  const {isLogin} = useSelector(models=>models.user);
  const history = useHistory();
  const params =  useParams();
  let {query: {redirect}} = useLocation() as any;
  useEffect(()=>{
    if (isLogin){
      redirect = redirect?decodeURIComponent(redirect): '/';
      history.replace(redirect)
    }
  },[isLogin])

  useEffect(()=>{
    dispatch({
      type:'user/login',
      payload:{user_name,user_pwd}
    })
  },[])
  return (
    <div>
      <h1>登录页</h1>
    </div>
  );
}
export default LoginPage
